<template>
  <view class="page">
    <view class="page">
      <view class="page-bd">
        <view class="page-title">CodeInput 验证码输入</view>
        <view class="demo-block">
          <view class="page-desc">基础使用</view>
          <d2-code-input v-model="codeVal" @change="change" @finish="onFinish"></d2-code-input>
        </view>
        <view class="demo-block">
          <view class="page-desc">自定义长度</view>
          <d2-code-input v-model="codeVal" @change="change" @finish="onFinish" :maxlength="6"></d2-code-input>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      codeVal: '123',
    }
  },
  created() {},
  methods: {
    change(val) {
      console.log('codeVal1', val);
      console.log('codeVal2', this.codeVal);
    },
    onFinish(val) {
      uni.showToast({ title: this.codeVal, icon: 'none' })
    },
  }
}
</script>

<style lang="scss" scoped>
.page {
  height: 100vh;
  background: #F8F8F8;
  &-bd {
    padding: 104rpx 32rpx 0;
  }
  &-title {
    font-weight: 600;
    font-size: 40rpx;
    color: #323233;
    line-height: 56rpx;
    margin-bottom: 40rpx;
  }
  &-desc {
    margin-bottom: 8rpx;
    font-weight: 400;
    font-size: 24rpx;
    color: #969799;
    line-height: 34rpx;
  }
}

.demo-block {
  margin-bottom: 20rpx;
}

</style>
